<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>iOS UIWebView Class Reference | 在路上</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="原文地址 属性allowsInlineMediaPlayback前端重点关注 是否允许页内播放视频，默认值NO，使用原生的全屏控制。 使用页面播放需要设置此属性为YES，并且video 元素要加上 webkit-playsinline属性。 canGoBack是否可以后退，只读属性 canGoForward是否可以前进，只读属性 dataDetectorTypes在webview被转换为可点击的U">
<meta name="keywords" content="JavaScript">
<meta property="og:type" content="article">
<meta property="og:title" content="iOS UIWebView Class Reference">
<meta property="og:url" content="http://yoursite.com/2012/10/30/iOS-UIWebView-Class-Reference/index.html">
<meta property="og:site_name" content="在路上">
<meta property="og:description" content="原文地址 属性allowsInlineMediaPlayback前端重点关注 是否允许页内播放视频，默认值NO，使用原生的全屏控制。 使用页面播放需要设置此属性为YES，并且video 元素要加上 webkit-playsinline属性。 canGoBack是否可以后退，只读属性 canGoForward是否可以前进，只读属性 dataDetectorTypes在webview被转换为可点击的U">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2018-03-26T11:35:06.692Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="iOS UIWebView Class Reference">
<meta name="twitter:description" content="原文地址 属性allowsInlineMediaPlayback前端重点关注 是否允许页内播放视频，默认值NO，使用原生的全屏控制。 使用页面播放需要设置此属性为YES，并且video 元素要加上 webkit-playsinline属性。 canGoBack是否可以后退，只读属性 canGoForward是否可以前进，只读属性 dataDetectorTypes在webview被转换为可点击的U">
  
    <link rel="alternate" href="/atom.xml" title="在路上" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">在路上</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">一位崇尚价值投资的 Web 开发者</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="搜索"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-iOS-UIWebView-Class-Reference" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2012/10/30/iOS-UIWebView-Class-Reference/" class="article-date">
  <time datetime="2012-10-29T16:00:00.000Z" itemprop="datePublished">2012-10-30</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      iOS UIWebView Class Reference
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p><a href="https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIWebView_Class/Reference/Reference.html" target="_blank" rel="noopener">原文地址</a></p>
<h2 id="属性"><a href="#属性" class="headerlink" title="属性"></a>属性</h2><h3 id="allowsInlineMediaPlayback"><a href="#allowsInlineMediaPlayback" class="headerlink" title="allowsInlineMediaPlayback"></a>allowsInlineMediaPlayback</h3><p><strong style="color:red;">前端重点关注</strong></p>
<p>是否允许页内播放视频，默认值NO，使用原生的全屏控制。</p>
<p>使用页面播放需要设置此属性为YES，并且video 元素要加上 <code>webkit-playsinline</code>属性。</p>
<h3 id="canGoBack"><a href="#canGoBack" class="headerlink" title="canGoBack"></a>canGoBack</h3><p>是否可以后退，只读属性</p>
<h3 id="canGoForward"><a href="#canGoForward" class="headerlink" title="canGoForward"></a>canGoForward</h3><p>是否可以前进，只读属性</p>
<h3 id="dataDetectorTypes"><a href="#dataDetectorTypes" class="headerlink" title="dataDetectorTypes"></a>dataDetectorTypes</h3><p>在webview被转换为可点击的URL内容的数据类型。</p>
<p>使用此属性可以指定譬如<code>http链接</code>，<code>Email地址</code>，<code>电话号码</code>等内容将自动转换为可点击的链接。当点击以后，webview寻找相应的应用程序来处理。</p>
<h3 id="delegate"><a href="#delegate" class="headerlink" title="delegate"></a>delegate</h3><p>委托，用于回调通知页面的加载状态，比如已经打开、打开完成或打开错误等。</p>
<h3 id="keyboardDisplayRequiresUserAction"><a href="#keyboardDisplayRequiresUserAction" class="headerlink" title="keyboardDisplayRequiresUserAction"></a>keyboardDisplayRequiresUserAction</h3><p><strong style="color:red;">前端重点关注</strong></p>
<p>显示键盘是否一定需要用户动作，默认值为YES，也就是用户必须主动点击可输入的表单元素以后才会显示键盘。</p>
<p>设置为NO以后，页面可以通过JS脚本的<code>focus</code>事件显示键盘。</p>
<h3 id="loading"><a href="#loading" class="headerlink" title="loading"></a>loading</h3><p>webview是否还在加载，只读属性</p>
<h3 id="mediaPlaybackAllowsAirPlay"><a href="#mediaPlaybackAllowsAirPlay" class="headerlink" title="#mediaPlaybackAllowsAirPlay"></a>#mediaPlaybackAllowsAirPlay</h3><p><strong style="color:red;">前端重点关注</strong></p>
<p>媒体播放是否允许<code>Air Play</code>???默认值为YES</p>
<h3 id="mediaPlaybackRequiresUserAction"><a href="#mediaPlaybackRequiresUserAction" class="headerlink" title="mediaPlaybackRequiresUserAction"></a>mediaPlaybackRequiresUserAction</h3><p><strong style="color:red;">前端重点关注</strong></p>
<p>媒体播放是否需要用户动作主动触发，默认值为YES。也就是说默认情况无法自动播放音频和视频。</p>
<p>那么默认设置下是不是一定无法自动播放呢？StackOverflow上找到一个<a href="http://stackoverflow.com/questions/4259928/how-can-i-autoplay-media-in-ios-4-2-1-mobile-safari" target="_blank" rel="noopener">方法</a>解决此问题（没有测试）</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> ifr = <span class="built_in">document</span>.createElement(<span class="string">"iframe"</span>);</span><br><span class="line">ifr.setAttribute(<span class="string">'src'</span>, <span class="string">"http://mysite.com/myvideo.mp4"</span>);</span><br><span class="line">ifr.setAttribute(<span class="string">'width'</span>, <span class="string">'1px'</span>);</span><br><span class="line">ifr.setAttribute(<span class="string">'height'</span>, <span class="string">'1px'</span>);</span><br><span class="line">ifr.setAttribute(<span class="string">'scrolling'</span>, <span class="string">'no'</span>);</span><br><span class="line">ifr.style.border=<span class="string">"0px"</span>;</span><br><span class="line"><span class="built_in">document</span>.body.appendChild(ifr);</span><br></pre></td></tr></table></figure>
<h3 id="request"><a href="#request" class="headerlink" title="request"></a>request</h3><p>webview当前请求的URL，只读属性</p>
<h3 id="scalesPageToFit"><a href="#scalesPageToFit" class="headerlink" title="scalesPageToFit"></a>scalesPageToFit</h3><p>指定页面是否按比例缩放适应webview，并且用户可以更改缩放比例。默认值为NO，用户不能更改缩放比例。</p>
<h3 id="scrollView"><a href="#scrollView" class="headerlink" title="scrollView"></a>scrollView</h3><p>webview关联的scroll view，只读属性</p>
<h3 id="suppressesIncrementalRendering"><a href="#suppressesIncrementalRendering" class="headerlink" title="suppressesIncrementalRendering"></a>suppressesIncrementalRendering</h3><p>当页面完全加载到内存以后，webview是否禁止增量内容渲染，默认值为NO</p>
<p>iOS 6.0版本支持</p>
<p>##实例方法</p>
<h3 id="goBack"><a href="#goBack" class="headerlink" title="goBack"></a>goBack</h3><p>加载历史记录当前页之前的页面</p>
<h3 id="goForward"><a href="#goForward" class="headerlink" title="goForward"></a>goForward</h3><p>加载历史记录当前页之后的页面</p>
<h3 id="loadData-MIMEType-textEncodingName-baseURL"><a href="#loadData-MIMEType-textEncodingName-baseURL" class="headerlink" title="loadData:MIMEType:textEncodingName:baseURL"></a>loadData:MIMEType:textEncodingName:baseURL</h3><p>设置页面内容，MIMIE type，编码，URL</p>
<h3 id="loadHTMLString-baseURL"><a href="#loadHTMLString-baseURL" class="headerlink" title="loadHTMLString:baseURL:"></a>loadHTMLString:baseURL:</h3><p>设置页面内容</p>
<h3 id="loadRequest"><a href="#loadRequest" class="headerlink" title="loadRequest"></a>loadRequest</h3><p>根据指定的URL进行异步连接</p>
<h3 id="reload"><a href="#reload" class="headerlink" title="reload"></a>reload</h3><p>重新载入当前页</p>
<h3 id="stopLoading"><a href="#stopLoading" class="headerlink" title="stopLoading"></a>stopLoading</h3><p>取消当前页的加载</p>
<h3 id="stringByEvaluatingJavaScriptFromString"><a href="#stringByEvaluatingJavaScriptFromString" class="headerlink" title="stringByEvaluatingJavaScriptFromString"></a>stringByEvaluatingJavaScriptFromString</h3><p><strong>前端重点关注</strong></p>
<p>在页面加载完成以后运行JavaScript脚本，运行脚本有如下注意事项：</p>
<ul>
<li>脚本运行不得超过10秒</li>
<li>将要执行的脚本内存分配不得超过10M</li>
</ul>
<p><a href="http://url.cn/7Vf4bx" target="_blank" rel="noopener">这里</a>有一个比较详细的教程可以参考</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2012/10/30/iOS-UIWebView-Class-Reference/" data-id="cjf865ufp000x8wp18zsm0pmk" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/JavaScript/">JavaScript</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2012/11/11/Ajax-Encoding/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          Ajax编码问题
        
      </div>
    </a>
  
  
    <a href="/2012/07/27/A-Cross-Domain-Practice/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">一次跨域实践</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript/">JavaScript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript-解析器/">JavaScript,解析器</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/React/">React</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Redux/">Redux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/SlimerJS/">SlimerJS</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/代码管理/">代码管理</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/持续集成/">持续集成</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签云</h3>
    <div class="widget tagcloud">
      <a href="/tags/JavaScript/" style="font-size: 20px;">JavaScript</a> <a href="/tags/JavaScript-解析器/" style="font-size: 10px;">JavaScript,解析器</a> <a href="/tags/React/" style="font-size: 16.67px;">React</a> <a href="/tags/Redux/" style="font-size: 10px;">Redux</a> <a href="/tags/SlimerJS/" style="font-size: 10px;">SlimerJS</a> <a href="/tags/代码管理/" style="font-size: 10px;">代码管理</a> <a href="/tags/持续集成/" style="font-size: 13.33px;">持续集成</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/09/">九月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">七月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/06/">六月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">三月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/02/">二月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/12/">十二月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/06/">六月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/05/">五月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/04/">四月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/07/">七月 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/06/">六月 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/11/">十一月 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/10/">十月 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/07/">七月 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/03/">三月 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/02/">二月 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2011/10/">十月 2011</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2010/01/">一月 2010</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/1970/01/">一月 1970</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/09/09/space/">空格</a>
          </li>
        
          <li>
            <a href="/2016/07/17/parser/">JavaScript Parser资源总结</a>
          </li>
        
          <li>
            <a href="/2016/06/29/slimerjs/">使用SlimerJS将网页输出为PDF</a>
          </li>
        
          <li>
            <a href="/2016/06/26/code-management/">代码管理</a>
          </li>
        
          <li>
            <a href="/2016/06/18/violet/">violet - 值得一试的写作同步小助手</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2018 Simon Xu<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



  </div>
</body>
</html>